//
//  JSInterface.m
//  JSDemo
//
//  Created by 坑爹的H5 on 16/7/21.
//  Copyright © 2016年 坑爹的H5. All rights reserved.
//

#import "JSInterface.h"

//#import "LoginViewController.h"

@implementation JSInterface
- (void) h5CallApp
{
    NSLog(@"success!");
}
- (void) h5CallApp: (NSString*) param And2: (NSString*) param2 And3: (NSString*) param3
{
    NSLog(@"test with param: %@ and param2: %@ and param3: %@", param, param2,param3);
}

//2 hide, 1 appear
- (void) showToast:(NSString *)arg{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"HIDEBOTTOM" object:arg];
}

- (void) loginOut{

//    LoginViewController *vc = [[LoginViewController alloc]init];
//    
//    [[UIApplication sharedApplication] delegate].window.rootViewController = vc;
//    
//    [[[UIApplication sharedApplication] delegate].window makeKeyAndVisible];
//    
//    //登出 清除缓存
//    NSUserDefaults *userInfo = [NSUserDefaults standardUserDefaults];
//    [userInfo removeObjectForKey:@"userName"];
//    [userInfo removeObjectForKey:@"password"];
  [[NSNotificationCenter defaultCenter]postNotificationName:@"LOGIN_OUT" object:nil];
    // 清除cookie
    [self deleteCookie];
    
}

- (void)deleteCookie{

    NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];

    NSArray *cookieAry = [cookieJar cookies];

    for (NSHTTPCookie *cookie in cookieAry) {

        [cookieJar deleteCookie:cookie];
    }
}




@end
